Memory controller, nonvolatile storage module, access module and nonvolatile storage system

ABSTRACT

When a write command is issued, new data is written into a free physical block of a nonvolatile memory ( 110 ). Here, if data of the same logical block has been written already, the block is erased and a recording state is judged by a recording state judgment unit ( 126 ). A physical block is swapped according to the number of write processes performed. Thus, it is possible to effectively perform a swap without increasing the number of write processes in a particular area, thereby increasing the lifetime of a nonvolatile storage module.

TECHNICAL FIELD

The present invention relates to a nonvolatile storage module such as asemiconductor memory card having a nonvolatile memory, a memorycontroller for controlling the nonvolatile memory, an access module andnonvolatile storage system formed by adding the access module as astructural element to the nonvolatile storage module.

BACKGROUND ART

A nonvolatile storage module having a rewritable nonvolatile memory,which is typified by a semiconductor memory card, has been increasinglydemanded as a removable storage device. Although the semiconductormemory card is much more expensive than an optical disc or a tape media,due to small size, light weight, seismicity and convenience in handling,it is in great demand as a recording medium for portable devices such asdigital still cameras and mobile phones. In recent years, with anincrease in capacity of the semiconductor memory card, application ofthe memory card to an alternative device for a hard disc of a personalcomputer and recording media for a digital television has beenconsidered.

The semiconductor memory card includes a flash memory as a nonvolatilemain memory and a memory controller for controlling the memory.According to instructions for reading and writing from the access moduleof the digital still camera and the personal computer, the memorycontroller controls reading and writing with respect to the flashmemory. Some non-removable nonvolatile storage modules are incorporatedinto the digital still camera and a portable audio equipment itself.

Since the flash memory requires a relatively long time to writing anderasing to and from a memory cell array as a storage unit, data in aplurality of memory cells can be collectively erased and written.Specifically, the flash memory includes a plurality of physical blocksand each physical block includes a plurality of pages. Erasure from theflash memory is performed in units of physical blocks and writing to theflash memory is performed in units of pages.

In recent years, in response to demands for larger capacity and lowercosts, a multi-level NAND flash memory which can store information oftwo bits in one memory cell as one type of the flash memory has become amainstream of the flash memory. In the multi-level NAND flash memory, itis difficult to ensure reliability of the memory cell and therefore, thenumber of times of rewriting is small. A conventional binary NAND flashmemory has the guaranteed number of times of rewriting of 100 thousandand guaranteed data retention time of 10 years. The multi-level NANDflash memory has the guaranteed number of times of rewriting of 10thousand or less and as shown in, for example, FIG. 1, trades off thenumber of times of rewriting for the data retention time.

The above-mentioned number of times of rewriting and data retention timeare directly connected to the lifetime of the nonvolatile storage modulesuch as the semiconductor memory card and lifetime of the nonvolatilestorage system including the nonvolatile storage module.

To extend the lifetime as long as possible, the conventional flashmemory employs an address management method called as wear leveling inwhich rewriting does not concentrate on a particular physical block. Forexample, in Patent document 1, in writing of data, the data is writtento a free physical block as a free area. At this time, when old datacorresponding to the logical address is stored, the old data stored inthe physical block is erased and the physical block is managed as a freeblock. This way is figured out so as not to concentrate writing on theparticular physical block. This is a method of writing data to the freearea, holding the old data until completion of data writing and usingthe free area including a spare area for replacement of a bad block toperform wear leveling.

However, in a nonvolatile semiconductor memory device in Patent document1, when the number of remaining free blocks becomes smaller, in a casewhere data at a certain logical address is rewritten many times, thedata is frequently moved between the free block and physical block towhich the data at the logical address is allocated. In other words, thenumber of times of rewriting of the certain physical block (hereinafterreferred to as alternate processing) increases rapidly. This phenomenonis hereinafter referred to as “localization of alternate area”.

To address this problem, for example, in a semiconductor disc device inPatent document 2, the number of times of rewriting of each physicalblock is held and data is swapped based on the number of times ofrewriting. Specifically, in rewriting data (data X), a physical block(physical block A) which stores an old version of the data X therein iserased and rewritten. In a case where the number of times of rewritingof the physical block A is large, the data X is written to anotherphysical block (physical block B) with the small number of times ofrewriting. However, when data Y has been already stored in the physicalblock B, the original data X in the physical block A is erased and then,the data Y is moved to the physical block A. After that, new data X iswritten to the physical block B. In this manner, when the data X isupdated thereafter, the physical block B is rewritten. As describedabove, dynamic wear leveling is achieved by performing swap between thephysical blocks A and B based on the number of times of rewriting.

Patent document 1: Japanese Unexamined Patent Publication No.2003-263894

Patent document 2: Japanese Unexamined Patent Publication No.1993-282880

DISCLOSURE OF INVENTION Problem to be Solved by the Invention

However, in Patent document 2, in rewriting of the data X, when anerroneous power disconnection occurs after the old version of the data Xis erased, the old data cannot be disadvantageously recovered.Furthermore, there is a system problem that swap processing causes anincrease in overheads of speed and power, resulting in that contentssuch as moving images requiring real-time storage cannot be recorded.

Thus, in consideration of the above-mentioned problems, an object of thepresent invention is to provide a memory controller, a nonvolatilestorage module, an access module, a nonvolatile storage system whichhave less localization of alternate area than conventional, have longlifetime and can recover old data even when power disconnection occurs.

Means to Solve the Problems

To solve the problems, a memory controller, connected to a nonvolatilememory, and reading and writing data according to an external accessinstruction, comprises: an address management unit for managing at leastfree area of said nonvolatile memory and selecting a writing destinationarea from the free area of said nonvolatile memory at data writing; arecording state judgement unit for performing swap necessity judgementof a storage area based on a recording state of said nonvolatile memory;and a reading and writing control unit for controlling data reading andwriting, determining a swap target area according to a judgement resultof said recording state judgement unit and performing swap processing.

Said recording state judgement unit may perform swap necessity judgementbased on numbers of times of rewriting of physical blocks whichconstitute said nonvolatile memory.

Said recording state judgement unit may judge necessity of swap based ona maximum value of said numbers of times of rewriting and one of anaverage value and a minimum value of said numbers of times of rewriting.

Said reading and writing control unit may determine a swap target areabased on numbers of times of rewriting of physical blocks whichconstitute said nonvolatile memory.

Said reading and writing control unit may determine a swap target areabased on numbers of times of rewriting of physical blocks whichconstitute said nonvolatile memory and depending on whether or not aphysical block is a free physical block.

Said memory controller further may include a lifetime judgement unit forjudging lifetime relating to a data retention time of data stored insaid nonvolatile memory and informing the lifetime information tooutside.

Said memory controller may further include a system condition receptionunit for receiving a system condition designated from outside and asystem condition judgement unit for performing swap possibilityjudgement of a storage area based on said system condition, and saidreading and writing control unit may control data reading and writingand performs determination of a swap target area and swap processingaccording to judgement results of said recording state judgement unitand said system condition judgement unit.

Said system condition may be at least one of a requirement relating toaccess speed, requirement relating to power, requirement relating topower and requirement relating to lifetime measure.

Said system condition judgement unit may determine a number of swapbased on said system condition.

Said system conditions reception unit may receive information on a typeof said nonvolatile memory, and said system condition judgement unitperforms swap possibility judgement according to the type of the saidnonvolatile memory.

Said system condition reception unit may receive information on a typeof said nonvolatile storage module mounting the memory controllerthereon, and said system condition judgement unit judges possibility ofswap according to the type of said nonvolatile storage module.

In addition, a nonvolatile storage module for reading and writing dataaccording to an external access instruction comprising: said nonvolatilememory; and said memory controller can be obtained.

An access module of the present invention is connected to thenonvolatile storage module for writing data to said nonvolatile storagemodule and reading data from said nonvolatile storage module andcomprises: a lifetime information display unit for displaying lifetimeinformation received from said nonvolatile storage module.

An access module of the present invention is connected to thenonvolatile storage module for writing data to said nonvolatile storagemodule and reading data from said nonvolatile storage module andcomprises: a system condition informing unit for informing said systemcondition to said nonvolatile storage module.

A nonvolatile storage system of the present invention comprises: anaccess module; and a nonvolatile storage module for reading and writingdata according to an access instruction from said access module, whereinsaid nonvolatile storage module includes: a nonvolatile memory; and oneof the a memory controllers mentioned above.

Effectiveness of the Invention

According to the present invention, based on determination of a writingdestination area by selection of the free area by the address managementunit, that is, wear leveling by the alternate processing, the recordingstate judgement unit performs the swap necessity judgement according tothe recording state and the reading and writing control unit performsdetermination of the swap target area and swap according to the swapnecessity judgement. Thus, the localization of alternate area as theabove-mentioned problem in Patent document 1 can be solved and thelifetime of the nonvolatile storage module can be extended. Furthermore,according to the present invention, since new data is written to thefree physical block, the power disconnection problem as the secondproblem in Patent document 2 can be solved.

Since the recording state judgement unit detects the alternate arealocalization, swap can be performed when the alternate area islocalized. Furthermore, the alternate area localization can be easilydetected based on the number of times of rewriting of the physicalblock. In addition, swap can be effectively performed by determining theswap target based on the number of times of rewriting or a state whetheror not the block is a free block in addition to the number.

BRIEF DESCRIPTION OF DRAWINGS

FIG. 1 is a graph showing reliability of a multi-level flash memory.

FIG. 2 is a block diagram showing a nonvolatile storage system inaccordance with a first embodiment of the present invention.

FIG. 3A is a memory map showing a physical area management table 131.

FIG. 3B is a memory map showing a logical-physical conversion table 132.

FIG. 4 is a circuit diagram showing an acquisition circuit 127A of PBsa.

FIG. 5 is a circuit diagram showing an acquisition circuit 127B of PBsb.

FIG. 6 is a memory map showing a lifetime table 128 a.

FIG. 7A is an explanatory view showing a recording state before writing.

FIG. 7B is an explanatory view showing a recording state after writing.

FIG. 7C is an explanatory view showing a recording state before swap.

FIG. 7D is an explanatory view showing a recording state after a firstswap.

FIG. 7E is an explanatory view showing a recording state after a secondswap.

FIG. 7F is an explanatory view showing a recording state after the third(last) swap.

FIG. 8 is a flow chart showing overall processing by a nonvolatilestorage module 100A in accordance with the first embodiment of thepresent invention.

FIG. 9 is a flow chart showing writing processing.

FIG. 10 is a flow chart showing recording state judgement processing.

FIG. 11 is a flow chart showing swap processing.

FIG. 12 is a flow chart showing lifetime judgement processing.

FIG. 13A is a memory map showing temporary update of the physical areamanagement table 131 at writing.

FIG. 13B is a memory map showing temporary update of thelogical-physical conversion table 132 at writing.

FIG. 14A is a memory map showing temporary update of the physical areamanagement table 131 at the first swap.

FIG. 14B is a memory map showing temporary update of thelogical-physical conversion table 132 at the first swap.

FIG. 15 is a block diagram showing a nonvolatile storage system inaccordance with a second embodiment of the present invention.

FIG. 16 is a flow chart showing overall processing by a nonvolatilestorage module 100B in accordance with the second embodiment of thepresent invention.

FIG. 17 is a flow chart showing system condition judgement processing.

FIG. 18 is a flow chart showing swap processing.

FIG. 19 is a time chart showing writing processing.

FIG. 20 is a diagram showing an example of system conditions.

FIG. 21 is a block diagram showing a nonvolatile storage system inaccordance with a third embodiment of the present invention.

FIG. 22 is a flow chart showing overall processing by a nonvolatilestorage module 100C in accordance with the third embodiment of thepresent invention.

FIG. 23 is a flow chart showing swap processing in accordance with thethird embodiment.

DESCRIPTION OF REFERENCE NUMERALS

-   100A, 100B, 100C Nonvolatile storage module-   120A, 120B, 120C Memory controller-   121 Host interface-   122 Buffer-   123 Memory interface-   124 CPU unit-   126 Recording state judgement unit-   127, 163, 173 Reading and writing control unit-   128 Lifetime judgement unit-   128 a Lifetime table-   130 Nonvolatile memory-   131 Physical area management table-   132 Logical-physical conversion table-   140, 150 Reading circuit-   141, 151 OR gate-   142, 144, 152, 154 Selector-   143, 145, 148, 153, 155, 158 Register-   146, 156 Comparator-   147, 157 AND gate-   161, 171 System condition reception unit-   162, 172 System condition judgement unit-   200A, 200B Access module-   201 Lifetime information display unit-   202 System condition informing unit

BEST MODE FOR CARRYING OUT THE INVENTION First Embodiment

FIG. 2 is a block diagram showing a nonvolatile storage system inaccordance with a first embodiment of the present invention. In FIG. 2,the nonvolatile storage system includes a nonvolatile storage module100A and an access module 200A. The access module 200A includes alifetime information display unit 201. The nonvolatile storage module100A includes a nonvolatile memory 110 and memory controller 120A. Thememory controller 120A includes a host interface (host IF) 121, a buffer122, a memory interface (memory IF) 123, a CPU unit 124, an addressmanagement unit 125, a recording state judgement unit 126, a reading andwriting control unit 127 and a lifetime judgement unit 128.

The nonvolatile memory 110 is a flash memory and has P physical blocks.The physical block is an erasing unit and all of the P physical blocksare used for data recording. The physical block is a writing unit andconsists of a plurality of pages. It is assumed that a logical spacewhich can be used by the access module 200A is L logical blocks. It isassumed that L is an integral number which is smaller than P. The (P−L)physical blocks are used as a spare area and management area. The sparearea is used as a work area at rewriting or alternate area of a badblock. The management area is an area for storing a physical areamanagement table 131 and logical-physical conversion table 132 therein.

The host interface (host IF) 121 is a block which is connected to theaccess module 200A through an external bus to receive commands forreading and writing data, logical address and data from the accessmodule 200A and sends data to the access module 200A in reading of thedata.

The memory interface (memory IF) 123 is connected to the nonvolatilememory 110 through a memory bus to write data temporarily stored in thebuffer 122 to the nonvolatile memory 110 according to an instruction ofthe reading and writing control unit 127 and reads data stored in thenonvolatile memory 110 to the buffer 122. The memory interface also swapdata between two physical blocks in the nonvolatile memory 110 accordingto an instruction of the reading and writing control unit 127.

The CPU unit 124 controls the whole of the memory controller 120A.

The address management unit 125 generates a physical address of thenonvolatile memory 110 based on the logical address received from theaccess module 200A according to the instruction of the reading andwriting control unit 127. The address management unit 125 includes thebelow-mentioned physical area management table 131 (expressed as PMT inthe figure) and logical-physical conversion table 132 (expressed as LPTin the figure). Hereinafter, the physical block is represented as PB,the logical block is represented as LB, a physical block number isrepresented as PBN, a logical block number is represented as LBN, thephysical block having the physical block number PBN of 0 is representedas PB0 and the logical block having the logical block number LBN of 0 isrepresented as LB0.

FIG. 3A is a memory map showing the physical area management table 131.The table 131 holds a block status BST, a select completion flag Srepresenting that the respective block has been already selected as aswap target and a number of times of rewriting WC, for each of thephysical block numbers PB0 to PB(P−1). In the block status, a value 0represents a used block, a value 1 represents a free block and a value 2represents a bad block. For simplification, in the present embodiment,it is assumed that there is no block having the value 2, that is, no badblock. Each time data writing processing is performed, the addressmanagement unit 125 detects a free block to which data is writtenreferring to the block status BST of the physical area management table131 according to the instruction of the reading and writing control unit127. The physical area management table 131 also holds the number oftimes of swap k and the total number of times of rewriting WCall. It isassumed that WCall is incremented by 1 each time writing to one logicalblock is performed in writing processing.

FIG. 3B is a memory map showing the logical-physical conversion table132 included in the address management unit 125. The conversion table132 holds the physical block number PBN corresponding to the logicalblock number LBN.

The recording state judgement unit 126 determines the recording statusof the nonvolatile memory 110, in particular, the localization ofalternate area, by appropriately referring to the physical areamanagement table 131 and outputs a swap necessity judgement result tothe reading and writing control unit 127.

The reading and writing control unit 127 writes data to the nonvolatilememory 110 according to the command from the access module 200A andreads data from the nonvolatile memory 110. When a write command isissued, the reading and writing control unit 127 outputs an instructionto acquire PBN of a free physical block to the address management unit125. The reading and writing control unit 127 has acquisition circuits127A, 127B for acquiring PBN as a swap target. The acquisition circuits127A, 127B are circuits for reading the physical block as a swap targetand a number of times of rewriting according to the swap necessityjudgement result outputted from the recording state judgement unit 126.

FIG. 4 is a block diagram showing the acquisition circuit 127A. In FIG.4, a reading circuit 140 is a circuit for sequentially reading thenumber of times of rewriting WC, physical block number PBN and blockstatus BST from the physical area management table 131 from the PBN withthe S flag of 0 according to a system clock SCK. At start of reading, aSTART flag is the value of 1 and is outputted to an OR gate 141. Each ofa selector 142 and selector 144 selects an A input when the output ofthe OR gate 141 is 0 and selects a B input when the output of the ORgate 141 is 1. A register 143 temporarily holds PBN and BST therein anda register 145 temporarily holds WC of the selected PB. A comparator 146compares the WC held in the register 145 (A input) with the number oftimes of rewriting WC read from the PBN with the next S flag of 0 (Binput), and the B input is smaller, a comparison output is defined as 0and outputted to the OR gate 141. The registers 143, 145 also give theoutputs to registers 148, 149. An AND gate 147 holds the outputs of theregisters 143, 145 when values of the system clock SCK and end flagrepresenting termination become 1. Thereby, as described later, physicalblock number PBN having the maximum number of times of rewriting and itsstatus BSP are held in the register 148. The maximum number of times ofrewriting M is held in the register 149.

FIG. 5 is a block diagram showing the acquisition circuit 127B includedin the reading and writing control unit 127. Like the abovementionedacquisition circuit 127A, the acquisition circuit 127B includes areading circuit 150, a OR gate 151, selectors 152, 154, registers 153,155, 158, a comparator 156 and an AND gate 157. The acquisition circuit127B has the comparator 156 which is different from the comparator 146in inequality sign. In addition, the acquisition circuit 127B has noregister corresponding to the register 149 and the other elements arethe same as those in the acquisition circuit 127A.

The lifetime judgement unit 128 includes a lifetime table 128 a shown inFIG. 6. The lifetime table 128 a is a table which records the dataretention time r with respect to the number of times of rewriting WCtherein in units of hours and is held in a read-only memory. Referringto the lifetime table 128 a, the lifetime judgement unit 128 judges thelifetime of the nonvolatile storage module 100A and informs the lifetimeto the access module 200A.

Operation of the nonvolatile storage system in accordance with the firstembodiment of the present invention will be described. First, thelocalization of alternate area and its suppression will be basicallydescribed and then, specific operation will be described.

[Localization of Alternate Area]

First, the recording state of the nonvolatile memory 110 will bedescribed. FIGS. 7A to 7F show the number of times of rewriting to thephysical blocks PB0 to PB (P−1) and LBN allocated to each of thephysical blocks or the physical block is a free block. FIG. 7A is anexplanatory view showing the recording state before writing, FIG. 7B isan explanatory view showing the recording state after writing and FIGS.7C to 7F are explanatory views showing the recording states before swap,after the first swap, after the second swap and after third (last) swap,respectively. Hereinafter, it is given that WC is the number of times ofrewriting, m is the minimum number of times of rewriting, a is theaverage number of times of rewriting, M is the maximum number of timesof rewriting, X is a threshold value representing a difference between amaximum value and average value of the number of times of rewriting tothe physical block for determining whether or not the swap processing isstarted.

In FIG. 7A, the physical blocks are divided into a PB group to whichdata hardly rewritten is allocated, PS to which data frequentlyrewritten (LB0 in the present embodiment) is allocated and free blockused for rewriting LB0.

Such recording state can occur in the case where the nonvolatile storagemodule is attached to a TV to record a TV program. Specifically, it isassumed that programs to be recorded for a long time in previouslyrecorded programs remain recorded in the nonvolatile storage module andprogram which are unnecessary to be recorded for a long time, such asnews, are frequently recorded and erased in a repeated manner. Here, itis assumed that the programs to be recorded for a long time correspondto the logical blocks LB1 to LB(L−1) and the program which areunnecessary to be recorded for a long time correspond to the logicalblock LB0. In this case, as shown in FIG. 7A, the number of times ofrewriting to the physical blocks PB1 to PB(P−3) for recording LB1 toLB(L−1) remains to be small and the number of times of rewriting WC tothe physical blocks PB0, PB(P−2), PB(P−1) used for recording and erasureof LB0 increases. Hereinafter, an area for the former is referred to asan occupied area and an area for the latter is referred to as analternate area. In FIG. 7A, a difference between the maximum number oftimes of rewriting M and the average number of times of rewriting a isequal to the threshold value X, which is a typical example of thelocalization of alternate area.

When the above-mentioned circumstance continues, the value of WC in thealternate area continuously increases, resulting in that the lifetime ofthe nonvolatile storage module early expires. Thus, in the nonvolatilestorage module 100A in the present embodiment, the recording statejudgement unit 126 detects the localization of alternate area based onWC, and the reading and writing control unit 127 performs swap based onthe number of times of rewriting to suppress the alternate arealocalization.

The alternate area localization is suppressed in following two steps.

(1) Detection of Alternate Area Localization

The recording state judgement unit 126 judges whether or not thelocalization of alternate area occurs according to a formula (1) andwhen the formula (1) holds, transmits judgement that swap is necessaryto the reading and writing control unit 127.

M−a>x  (1)

A specific calculation method will be described later. The thresholdvalue X may be determined depending on a processing capacity of thenonvolatile storage module 100A and reliability of the nonvolatilememory 110.

(2) Swap Processing

(2-1) Selection of Swap Target

A swap target PB is selected from the alternate area (area in which WCis larger than a) in a descending order of the number of times ofrewriting and a swap target PB is selected from the occupied area (areain which WC is smaller than a) in an ascending order of the number oftimes of rewriting. When the swap targets PB are collectively selectedat detection of the localization of alternate area, since overheads ofselection processing in terms of time are problematic, the swap targetsPB necessary for the next swap processing are selected for each writingor swap of one block.

(2-2) Prohibition of Duplicate Swap

When the same swap target is continuously selected, useless swap isrepeated and therefore, to prevent this, duplicate selection isprohibited until the predetermined number of times of swap is completed.Given that the predetermined number of times of swap is K1, K1 is foundaccording to a formula (2). Where, in the formula (2), MIN represents afunction taking a minimum value.

K1=MIN (the number of PB which satisfies WC>a, the number of PB whichsatisfies WC<a)  (2)

(2-3) Execution of Swap

By swapping the alternate area and occupied area of the block as theswap target thus determined, the alternate area, that is, an area inwhich the number of times of rewriting is conspicuous is dispersed.

In the above-mentioned suppression of the alternate area localization,detection of the alternate area localization and swap processing will bedescribed below referring to a flow chart of FIG. 8 showing overallprocessing and flow charts of FIG. 9 and subsequent figures showing eachprocessing. For simplification, it is assumed that, in data writing, awrite command is transmitted for each logical block. If the nonvolatilestorage module 100A automatically performs the swap processing when anaccess instruction is not issued from the access module 200A, data canbe destroyed due to an error such as power disconnection. This isirrational to the user. Therefore, the swap processing is basicallyperformed according to the access instruction of the access module 200A.In the present embodiment, each time the write command is received, theswap processing is performed together with the writing processing.

When the nonvolatile storage module 100A is attached to the accessmodule 200A, power source is fed from the access module 200A to thenonvolatile storage module 100A and the nonvolatile storage module 100Astarts initialization processing (S100). In the initializationprocessing, the memory controller 120A reads the physical areamanagement table 131 and logical-physical conversion table 132 which areheld in the management area of the nonvolatile memory 110 to a RAMprovided in the address management unit 125. At this time, the physicalarea management table 131 and logical-physical conversion table 132 holdinformation shown in FIGS. 3A and 3B, respectively, which corresponds tothe recording state shown in FIG. 7A.

In a case where an access is made from the access module 200A after that(S101), the CPU unit 124 analyzes a command transmitted from the accessmodule 200A (S102). In a case where the command is the write command,the procedure proceeds to S103 and shifts to a series of processing fromwriting to swap, and in a case where the command is the other commandsuch as a read command, the procedure proceeds to S106.

Here, it is assumed that LB0 is updated and the write command to writenew data is issued. The new data is held in the buffer 122 once. Next, aseries of processing from writing to swap will be described referring toFIG. 9. First, at S103, the writing processing is performed. FIG. 9shows details of the writing processing. At S200, the reading andwriting control unit 127 instructs the address management unit 125 toacquire the free physical block of a writing destination (hereinafterreferred to as free PB). The address management unit 125 searches PBfrom a leading address in the physical area management table 131. Astart position of search of the free PB by the address management unit125 is set to the leading address for each initialization processing,and normal processing after the initialization processing, searchcontinues from the address searched last time and when search reaches atrailing address, that is, PB(P−1), search returns to the leadingaddress. In this case, since initialization is completed, PB with thevalue of BST of 1 is searched from the leading address PB0 in theascending order.

FIG. 13A is a memory map showing temporary update of the physical areamanagement table 131 at writing and FIG. 13B is a memory map showingtemporary update of the logical-physical conversion table 132 atwriting. Since PB (P−2) is the first free block in the state on a leftside of FIG. 13A, this block is informed to the reading and writingcontrol unit 127 as a writing destination block number. In FIG. 13A, theregisters 148, 158 of the acquisition circuits 127A, 127B are registersfor temporarily holding PBN and block status BST of the PBs (PBsa andPBsb) as the swap targets therein. PBsa is the swap target blockbelonging to the area in which the number of times of rewriting islarger, that is, the alternate area, while PBsb is the swap target blockbelonging to the area in which the number of times of rewriting issmaller, that is, the occupied area.

Subsequently, referring to the logical-physical conversion table 132shown in the left side of FIG. 13B, an area in which old data in LB0 isrecorded, that is, PB0 is acquired. Next, as shown in FIG. 13A, in thephysical area management table 131, the value of BST of PB0 istemporarily updated to 1 and the value of BST of PB (P−2) is temporarilyupdated to 0. Furthermore, since the number of times of rewriting of PB0increases by 1 by erasure processing of the old data at S205 describedlater, as shown in FIG. 13A, WC to PB0 is temporarily updated from a+Xto a+W+1. As shown in FIG. 13B, the physical block address PBNcorresponding to LB0 in the logical-physical conversion table 132 istemporarily updated from 0 to P−2 (S201).

At S202 in FIG. 9, the reading and writing control unit 127 transmits awrite instruction to write new data in LB0 and writing destination blocknumber (P−2) to the memory interface 123. The memory interface 123starts to write data in LB0, which is temporarily stored in the buffer122, to the PB (P−2) of the nonvolatile memory 110. The reading andwriting control unit 127 performs processing at S203, S204 by the timethat writing is completed.

At S203 in FIG. 9, the reading and writing control unit 127 reads thetotal number of times of rewriting WCall (current value) from thephysical area management table 131 and holds WCall obtained by adding 1to the WCall in the physical area management table 131 again as newWCall. At S204, the reading and writing control unit 127 selects thephysical blocks PBsa and PBsb as the swap targets referring to thephysical area management table 131 (S204). Specifically, among PBshaving the value of the select completion flag S of 0 in the physicalarea management table 131, that is, “PBs which are not selected as theswap target”, PBN and BST of PB having a maximum value of WC are held inthe register 148 of the reading and writing control unit 127 and PBN andBST of PB having a minimum value of WC are held in the register 158 ofthe reading and writing control unit 127.

The maximum value of WC is detected by the acquisition circuit 127A ofthe reading and writing control unit 127. In FIG. 4, the physical areamanagement table 131 sequentially reads WC, PBN and BST of PBN havingthe value of the S flag of 0 from the leading address of the physicalarea management table 131 in ascending order by the reading circuit 140according to the system clock SCK. At start of reading, that is, atreading of PB0 in FIG. 4, the value of the START flag becomes 1 and theB inputs of the selector 142 and selector 144 are selected through theOR gate 141. In other words, WC (a+X+1) of PB0 is temporarily held inthe register 145 and PBN (0) and BST (0) of PB0 are temporarily held inthe register 143. According to the next SCK, the value of the START flagbecomes 0, information on PB1 in the physical area management table 131is read from the reading circuit 140 and the comparator 146 comparesWC(a+X+1) of PB0 with WC(m) of PB1. Since the B input (m) is smallerthan the A input (a+X+1), the comparison output becomes 0 and S inputsof the selector 142 and selector 144 through the OR gate 141 become 0.As a result, PBN and BST which are temporarily held in the register 143are temporarily held in the register 143 again. Meanwhile, WCtemporarily held in the register 145 is temporarily held in the register145 again. When the above-mentioned operation is repeated from PB0 to PB(P−1), at the time when reading from PB (P−1) is finished, the value ofthe END flag becomes 1 and the register 148 holds PBN and BST whichcorrespond to PB with the maximum number of times of rewriting therein.In other words, given that the maximum number of times of rewriting M isa+X+1, PB0 is selected as PBsa. The register 148 in FIG. 13A shows thisstate. When the value of the END flag becomes 1, the register 149 holdsWC corresponding to the maximum number of times of rewriting of PB, thatis, the maximum number of times of rewriting M therein.

The minimum value of WC is detected by the acquisition circuit 127B ofthe reading and writing control unit 127. The processing is basicallysimilar to the processing by the acquisition circuit in FIG. 4 and adifference is that an output condition of the comparator 156 is B<A. Dueto the difference, the register 158 of the acquisition circuit 127Bholds PBN and BST corresponding to PB with the minimum number of timesof rewriting therein. In other words, given that the minimum number oftimes of rewriting is m, PB1 is selected as PBsb. The register 158 inFIG. 13A holds the PBN and BST therein.

In FIG. 9, after writing of the new data is finished and the reading andwriting control unit 127 selects PBsa and PBsb as the swap targets, theold data is erased (S205). In erasure of the old data, the reading andwriting control unit 127 instructs the address management unit 125 tosearch PB which stores the old data in LB0. Referring to thelogical-physical conversion table 132, the address management unit 125informs PBN held in LB0, that is, PB0 as an erasure target block to thereading and writing control unit 127. After that, according to controlby the reading and writing control unit 127, the memory interface 123erases data in the physical block address PB0.

After processing up to S205 is finished, the reading and writing controlunit 127 rewrites the physical area management table 131 andlogical-physical conversion table 132, which are temporarily updated inthe RAM of the address management unit 125 into a management area of thenonvolatile memory 110 through the memory interface 123 (S206). In thismanner, the tables 131, 132 are updated. Then, the writing processingS103 shown in FIG. 8 finishes. FIG. 7B shows a state where writingfinishes and the number of times of rewriting M to PB0 increases.

Next, the procedure shifts to recording state judgement processing(S104). FIG. 10 is a flow chart showing details of the recording statejudgement processing. First, the recording state judgement unit 126calculates the average number of times of rewriting a according to aformula (3) (S300). Here, the recording state judgement unit 126 refersto WCall from the physical area management table 131. P is the totalnumber of the physical blocks of the nonvolatile memory 110.

a=WCall/P  (3)

Given that P is 4096, it is preferred that WCall expressed in binarynumber is shifted to the right by 12 bits to calculate a. Since a is aparameter which permits a small margin or error, when P is not a powerof 2, P may be approximately factored to a plurality of values of powerof 2 to perform calculation by combination of shift operation andaddition. Thereby, calculation load can be reduced.

After that, the recording state judgement unit 126 judges a swapnecessity flag (hereinafter referred to SWF1) held therein (S301). In acase where the value of the flag is 1, processing is finished and whenSWF1 is 0, the procedure proceeds to swap necessity judgement (S302).When the formula (1) holds at S302, the alternate area is localized. Inthis case, to suppress the alternate area localization, swap processingis performed. In the swap processing, first, the target number of timesof swap K1 is calculated according to the formula (2) (S303), the valueof the flag SWF1 is set to 1 and based on the swap necessity judgementresult, a swap instruction is issued to the reading and writing controlunit 127 (S304).

Here, in the recording state of the nonvolatile memory 110 shown in FIG.3A, the number of PB with WC which is larger than the average number oftimes of rewriting a is three and the number of PB with WC which issmaller than the average number of times of rewriting a is 4093.Accordingly, the target number of times of swap K1 is three according tothe formula (2) and the swap processing is performed three times.

Thus, the recording state judgement processing (S104) shown in FIG. 8 isfinished and the procedure proceeds to the swap processing (S105). Thereading and writing control unit 127 performs the swap processingaccording to the flow chart of FIG. 11. First, the reading and writingcontrol unit 127 finished processing without performing the swapprocessing when the value of SWF1 received from the recording statejudgement unit 126 is 0 and shifts to processing at S401 and subsequentprocessing when the value of SWF1 is 1.

FIG. 14A is a memory map showing temporary update of the physical areamanagement table 131 at the first swap and FIG. 14B is a memory mapshowing temporary update of the logical-physical conversion table 132 atthe first swap.

At S401, based on the information held in the registers 148, 158 shownin FIG. 13A, the reading and writing control unit 127 instructs theaddress management unit 125 to temporarily update BSTs and S flags ofPB0 and PB1 as the swap targets in the physical area management table131. The reading and writing control unit 127 also instructs the addressmanagement unit 125 to temporarily update PBN corresponding to thelogical block LB0 as the swap target in the logical-physical conversiontable 132. As a result, physical area management table 131 istemporarily updated as shown in FIG. 14A and the logical-physicalconversion table 132 is temporarily updated as shown in FIG. 14B.

After that, at S402, referring to the register 148 and register 158, thereading and writing control unit 127 determines a swap procedure so asto issue a swap instruction of PBsa and PBsb. Here, PB0 as the free PBis swapped with PB1 as the used PB as shown in FIG. 7C, a procedurecorresponding to following steps 1 to 3 is informed to the memoryinterface 123.

Step 1: Reading of data in LB1 from PB1

Step 2: Writing of the read data in LB1 to PB0

Step 3: Erasure of PB1

Based on this, the memory interface 123 starts the swap processing.

By performing the steps 1 to 3 in this manner, the recording state inFIG. 7C is changed to the recording state in FIG. 7D. In other words,data in LB1 is written to PB0 and PB1 becomes a free PB.

During the swap processing is performed, the reading and writing controlunit 127 reads the number of times of swap k held in the physical areamanagement table 131 and increments k (S403) and then, compares k withthe target number of times of swap K1 (S404). When k does not reach K1,that is, swap needs to be continued, the number of times of rewriting ofPB1 increases by 1 by erasure of PB1 in the swap processing currentlyperformed. Accordingly, the reading and writing control unit 127 readsWCall (current value) from the physical area management table 131 andholds WCall obtained by adding 1 to the WCall in the physical areamanagement table 131 as new WCall again (S409).

Furthermore, as in the above-mentioned processing at S204, the readingand writing control unit selects the next swap targets PBsa and PBsb andas shown in FIG. 14A, holds PBN and BST of PB(P−2) in the register 148and PBN and BST of PB2 in the register 158 (S410). After that, at S411,the reading and writing control unit 127 rewrites the physical areamanagement table 131 and logical-physical conversion table 132 to thenonvolatile memory 110 through the memory interface 123 and theprocedure returns to S400.

Then, swap-related processing at S400 and subsequent steps is performed.Here, since both PB2 and PB (P−2) are used PB, the swap processing isperformed by using a free PB, for example, PB (P−1) as an intermediatebuffer. In such case, three-staged processing of swap a, b, c as shownin FIG. 7D is required. Accordingly, the recording state of thenonvolatile memory 110 in FIG. 7D is changed to that in FIG. 7E and thenumber of times of rewriting increases by 2PB of PB (P−2) and PB (P−1).According to following rules, WCall changes depending on the way ofswap.

(1) When both the swap targets are free PBs, WCall increases by 0.

(2) When one swap target is a free PB and the other swap target is aused PB, WCall increases by 1.

(3) When both the swap targets are used PBs, WCall increases by 2.

In the present embodiment, swap (1) is impossible. When the reading andwriting control unit 127 performs the swap-related processing K1 times(three times), as shown in FIG. 7F, all alternate areas are replacedwith the occupied areas and then, the procedure shifts from S404 toS405.

At S405, the number of times of rewriting of PB3 increases by 1 by thethird swap processing and therefore, the reading and writing controlunit 127 adds 1 to WCall and resets all S flags in the physical areamanagement table 131 (S406). After SWF1 and the number of times of swapk are reset (S407), the reading and writing control unit 127 rewritesthe physical area management table 131 and logical-physical conversiontable 132 to the nonvolatile memory 110 (S408) and completes the swapprocessing.

Finally, operation of the lifetime judgement unit 128 will be described.When the access module 200A issues a lifetime request command to thenonvolatile storage module 100A, in the flow chart of FIG. 8 showingoverall processing, the procedure proceeds to S106 and the lifetimejudgement unit 128 performs lifetime judgement processing according tothe flow chart of FIG. 12. When the host interface 121 receives thelifetime request command, the host interface 121 informs the receptionto the lifetime judgement unit 128 and the lifetime judgement unit 128performs judgement at S500 and then, instructs the reading and writingcontrol unit 127 to acquire the maximum number of times of rewriting M.

The reading and writing control unit 127 holds the maximum number oftimes of rewriting M in the register 149 by the processing by theacquisition circuit 127A of the above-mentioned processing at S204 andoutputs the END flag to the lifetime judgement unit 128. When thelifetime judgement unit 128 receives the END flag, the lifetimejudgement unit 128 acquires the maximum number of times of rewriting Mheld in the register 149 (S501) and reads the lifetime table 128 a shownin FIG. 6 (S502). In reading, the lifetime judgement unit 128 determinestwo values which are the closest to the maximum number of times ofrewriting M in the number of times of rewriting WC on the lifetime table128 a. Given that WC which is smaller than M is WC1 and WC which islarger than M is WC2, data retention times r (WC1) and r (WC2) whichcorrespond to WC1 and WC2, respectively, are read (S502). For example,in a case where M is 180, WC1 is 100, WC2 is 200, r (WC1) is 501187 andr (WC2) is 116906. Dimension of r is hour.

After that, interpolation calculation is performed according to aformula (4) (S503).

r(M)=r(w1)+α{r(w2)−r(w1)}  (4)

Where, α=(M−w1)/(w2−w1)

For example, when M is 180, r (M) becomes 193762 (hours). A lifetimejudgement block 28 informs r (M) as a calculation result to the accessmodule 200A through the host interface 121 as lifetime information(S504).

When the access module 200A receives r (M), the lifetime informationdisplay unit 201 displays r (M). Since the value of r (M) is large in acase where M is 180, dimension may be changed to year in display. In thepresent embodiment, the nonvolatile storage module 100A informs thelifetime information in response to the lifetime request command fromthe access module 200A. Alternately, the nonvolatile storage module 100Amay appropriately make an interrupt to the access module 200A and informthe lifetime information.

As described above, in the nonvolatile storage system in the firstembodiment, based on determination of the writing destination PB byselection of the free PB by the address management unit 125, that is,wear leveling by the alternate processing, the recording state judgement126 performs swap necessity judgement according to the formula (1), thatis, depending on the recording state, and the reading and writingcontrol unit 127 determines the swap target blocks (PBsa, PBsb)according to the swap necessity judgement and performs swap. Thereby,“localization of alternate area” is suppressed and it is prevented thatold data cannot be reproduced due to the “power disconnection problem”.

Since the lifetime judgement unit 128 finds the data retention time andinforms it to the access module 200A, the user recognizes the lifetimeof the nonvolatile storage module and can record data in ease. Throughswap, the alternate area localization is suppressed and the number oftimes of rewriting of PB in the nonvolatile memory 110 is leveled.Therefore, the data retention time corresponding to the maximum numberof times of rewriting M or the average number of times of rewriting a,that is, the lifetime information informed to the access module 200A canbe regarded as the data retention time of any record information in thenonvolatile memory 110. In other words, the lifetime information can beregarded as the lifetime of the nonvolatile storage module.

Although the recording state judgement unit detects the alternate arealocalization based on the maximum value and average value of the numberof times of rewriting in the first embodiment, the recording statejudgement unit may detect the alternate area localization based on theother values such as the maximum value and minimum value of the numberof times of rewriting. Furthermore, although the reading and writingcontrol unit determines the swap target areas based on the number oftimes of rewriting, the swap target areas may be determined depending onwhether or not the physical block is a free block along with the numberof times of rewriting. When one of the physical blocks as the swaptargets is limited to a free block, the three-staged processing shown inFIG. 7D becomes unnecessary and therefore, swap is finished through oneprocessing as shown in FIG. 7C or 7E.

Furthermore, by using only a physical block having a number of times ofrewriting close to its maximum value, and a physical block having anumber of times of rewriting close to its minimum value, as the swaptarget area, the number of times of swap may be reduced.

Second Embodiment

FIG. 15 is a block diagram showing a nonvolatile storage system inaccordance with a second embodiment of the present invention. In FIG.15, the nonvolatile storage system includes a nonvolatile storage module100B and access module 200B. The access module 200B is obtained byadding a system condition informing unit 202 to the access module in thefirst embodiment. The nonvolatile storage module 100B includes a memorycontroller 120B and nonvolatile memory 110. The memory controller 120Bis obtained by adding a system condition reception unit 161 and systemcondition judgement unit 162 to the memory controller 120A in the firstembodiment. The reading and writing control unit 163 is a modificationof the reading and writing control unit 127 in the first embodiment. Theother blocks are similar to those in the nonvolatile storage module inthe first embodiment in FIG. 1.

Operation of the nonvolatile storage system thus configured inaccordance with the second embodiment of the present invention will bedescribed. FIG. 16 is a flow chart showing overall processing in thesecond embodiment of the present invention, FIG. 17 is a flow chartshowing system condition judgement processing, FIG. 18 is a flow chartshowing swap processing and FIG. 19 is a time chart showing writingprocessing.

A basic operation is similar to that of the nonvolatile storage systemin the first embodiment and a difference in that it is judged whether ornot the swap processing can be performed in a scope which satisfiessystem conditions such as writing speed or power received from theaccess module 200B, and in a case where the swap processing is possiblehow much swap processing can be performed. Then, the swap processing isperformed based on the swap possibility judgement.

In the overall processing shown in FIG. 16, first, the module performsthe initialization processing and waits an access from the access module200B. Here, it is assumed an access from the access module 200B is madeand the write command is issued (S602). In data writing, as shown inFIG. 19, the access module 200B transmits the write command, startlogical block number (LBN_S) as an argument of the command and systemconditions. The system condition reception unit 161 receives the systemconditions through the host interface 121 (S603). After that, data isintermittently transmitted every one logical block (hereinafter referredto as 1 LB). The access module 200B transmits a termination command notshown at the time when a necessary amount of data is transmitted andterminates the writing processing.

FIG. 20 shows an example of the system conditions. In the presentembodiment, the system conditions include three conditions: a basiccondition, speed condition and power condition. The basic condition is aflag representing possibility of a lifetime measure, and in a case wherethe value of the flag is 0, the lifetime measure is forcedly prohibitedin despite of the speed condition and power condition. When the value ofthe flag is 1, the lifetime measure is made available. In this case, thenonvolatile storage module 100B judges possibility of the swapprocessing by the reading and writing control unit 163 and so onaccording to their capabilities in response to the speed condition andpower condition described later.

The speed condition is a condition relating to a guarantee speed ofwriting data to the nonvolatile storage module 100B and writing must beperformed in the scope which satisfies the speed condition. Tg in thespeed condition represents a transmission time interval in units of 1LB. In the example of the system conditions in FIG. 20, data of 1 LB istransmitted every second. Given that the capacity of 1 LB is 1 MByte, anecessary transmission rate is 1 MByte/second. Tt represents a timeduring which data of 1 LB is actually transmitted. In other words, Tg−Ttrepresents a time during which data is not transmitted.

The power condition is a condition relating to an allowable power Pa(maximum power) which can be fed to the nonvolatile storage module 100Band at least writing must be performed in the scope which satisfies thispower condition.

After the system conditions are received at S603, the procedure shiftsto a series of processing from writing to swap at S604 and subsequentsteps. In the series of processing from writing to swap, the memorycontroller 120B performs writing processing and recording statejudgement processing at S604 and S605 as in S103, S104 in the firstembodiment, and then, the system condition judgement unit 162 performsthe system condition judgement processing (S606).

FIG. 17 shows the system condition judgement processing, in which thejudgement unit judges whether or not the value of a lifetime measurepossibility flag is 1, which represents a basic condition (S700). If thevalue of the flag is 0, the judgement unit finishes the judgementprocessing. When the value of the flag is 1, the procedure proceeds toS701, S702 and the judgement unit calculates the possible number oftimes of swap K2 t based on the speed condition and the possible numberof times of swap K2 p based on the power condition.

Based on the speed conditions Tg, Tt and time Ts required to performswap per 1 LB, the system condition judgement unit 162 calculates K2 taccording to a formula (5).

K2t=int{(Tg−Tt)/Ts}  (5)

Where, int is a function taking an integral value. However, since thesevalues vary depending on the way of swap as described above, incalculation of the formula (5), the system condition judgement unit 162receives swap type information from the reading and writing control unit163 and then, determines Ts.

Based on the power condition Pa and power Ps required to perform swapper 1 LB, the system condition judgement unit 162 calculates K2Paccording to a formula (6).

K2p=int(Pa/Ps)  (6)

After S702, the system condition judgement unit 162 calculates thepossible number of times of swap K2 according to a formula (7) (S703).Where, MIN is a function taking a minimum value.

K2=MIN(K2t,K2p)  (7)

After that, when k2 is not 0 (S704), the system condition judgement unit162 sets the value of a swap possibility flag SWF2 to 1 (S705) andterminates processing.

Following the above-mentioned system condition judgement processing(S606), at S607, the swap processing is performed. The swap processingin FIG. 18 is substantially similar to the above-mentioned swapprocessing in FIG. 11. Differences are as follows: it is judged whetheror not both the swap necessity flag SWF1 and swap possibility flag SWF2are set at S800, and after S804, the number of times of swap k iscompared with the possible number of times of swap K2 (S809). As aresult of the comparison judgement, when k does not reach K2, there is aroom to perform swap, and thus, the procedure shifts to S810 andcontinues the swap processing. As a result of the comparison judgement,when k reaches K2, there is no room to perform swap, and thus, theprocedure shifts to S805 and terminates the swap processing.

The above-mentioned processing is performed until the end command istransmitted (S608), and after reception of the end command, the value ofthe swap possibility flag SWF2 is reset to 0 and the next access iswaited (S609).

As described, in the second embodiment, in addition to “swap necessityjudgement based on the recording state” in the first embodiment, “swappossibility judgement based on the system conditions” is performed.Thus, it is possible to reduce overheads of speed and power, and tosolve, for example, the system problem that contents requiring real-timestorage, such as moving images, cannot be recorded.

Although the system condition is received as the argument of the writecommand, a command dedicated to inform the system condition may be used.Furthermore, the nonvolatile storage module 100B may provide a switchand may switch the possibility of the lifetime measure and so on as thebasic condition shown in FIG. 20 by the operation of the switch.

Although K2 s and K2 p are calculated according to the formula (5) andformula (6) in the present embodiment, the nonvolatile storage module100B may be provided with tables showing relationship between the speedcondition and the number of times of swap K2 s, and between the powercondition and the number of times of swap K2 p, respectively, anddetermine the values of K2 s and K2 p by referring to these tables whenthe system conditions are given.

Third Embodiment

FIG. 21 is a block diagram showing a nonvolatile storage system inaccordance with a third embodiment of the present invention. Thenonvolatile storage system includes a nonvolatile storage module 100Cand an access module 200A. The access module 200A is same as the accessmodule in the first embodiment. The nonvolatile storage module 100Cincludes a system condition reception unit 171, system conditionjudgement unit 172 and reading and writing control unit 173, and theother blocks are similar to those in the nonvolatile storage system inthe second embodiment shown in FIG. 15.

Operation of the nonvolatile storage system thus configured inaccordance with the third embodiment of the present invention will bedescribed. FIG. 22 is a flow chart showing processing by the nonvolatilestorage module 100C in accordance with the third embodiment of thepresent invention. A basic operation of the nonvolatile storage systemis similar to that of the nonvolatile storage system in the secondembodiment and a difference is that the system condition judgement unit172 judges the lifetime measure based on an ID code representing thetype of the nonvolatile memory.

In initialization processing (S900) shown in FIG. 22, the reading andwriting control unit 173 reads the ID code from the nonvolatile memory110 through the memory interface 123 and the system condition receptionunit 171 receives the ID code. The ID code is information on the type ofthe nonvolatile memory 110, which is previously held in the ROM or thelike in the nonvolatile memory 110, and represents that the nonvolatilememory is a highly reliable nonvolatile memory (for example, binary NANDflash memory) or low reliable nonvolatile memory (for example,multi-level NAND flash memory).

The module waits an access from the access module 200A. When there is anaccess, the procedure proceeds from step S901 to S902 and it is judgedwhether or not a command is the write command. If the command is thewrite command, the procedure proceeds to S903 and the writing processingand recording state judgement processing are performed. Recordingprocessing (S903) and recording state judgement processing (S904) aresame as the processing in FIG. 9 and the processing in FIG. 10,respectively. When the recording state is judged, the system conditionjudgement processing is performed. The system condition judgement unit172 interprets the ID code received by the system condition receptionunit 171 as a judgement reference in judgement of the lifetime measure.Specifically, in a case of the ID code value representing the highlyreliable nonvolatile memory, it is judged that a reliability measure bythe swap processing is unnecessary and the system condition judgementprocessing is finished. In the case of the ID code value representingthe low reliable nonvolatile memory, it is judged that the lifetimemeasure is available (S905). When the lifetime measure is unavailable,the processing is finished and when the lifetime measure is available,the procedure proceeds to S906 and the flag SWF2 is set, and then, theprocedure proceeds to S907 to perform the swap processing.

FIG. 23 is a flow chart showing swap processing in accordance with thethird embodiment. When swap is started, first, at S1000, it is judgedwhether or not both the values of the flags SWF1 and SWF2 are 1. Whenthe values are not 1, the processing is finished and when the values are1, the procedure proceeds to S1001. Concerning subsequent processing, asin the first embodiment shown in FIG. 11, the swap processing isperformed.

As described above, since the system condition judgement unit 171performs the swap possibility judgement based on the ID code of thenonvolatile memory 110, that is, the reliability of the nonvolatilememory 110, useless swap processing need not be performed, enablingreduction of overheads of power and speed for the swap processing.

A memory card ID code for identifying the type of the nonvolatilestorage module may be used as the ID code. In this case, the type of thenonvolatile storage module 100C is previously written to a part of therecording area of the nonvolatile memory 110 by the manufacturer, andthe system condition judgement unit 172 performs the swap possibilityjudgement based on the memory card ID code in the initializationprocessing.

The memory card ID code is a code representing that the memory card is aRAM-type memory card or WOM-type memory card, that is, the memory cardto which data can be written only once. The system condition judgementunit 172 interprets the memory card ID code read from the nonvolatilememory 110 by the system condition reception unit 171 as a judgementreference of the lifetime measure. Specifically, in the case of thememory card ID code representing the WOM-type memory card, it is judgedthat a reliability measure by the swap processing is unnecessary. In acase of a memory card ID code value representing the RAM-type memorycard, the procedure returns to S901 without performing the lifetimemeasure.

In this manner, the system condition judgement unit 172 performs theswap possibility judgement based on the memory card ID code of thenonvolatile storage module 100C, that is, the type of the nonvolatilestorage module. For this reason, useless swap processing need not beperformed, enabling reduction of overheads of power and speed for theswap processing.

Although the address management unit 125 determines a free PB acquiredby cyclically searching the physical area management table 131 as awriting destination PB in the first to third embodiments, the free PBwith the smaller WC of all PB may be preferentially determined as awriting destination PB. A free PB randomly selected from all free PBsmay be determined as a writing destination PB.

Although the swap processing is performed along with the writingprocessing performed each time the write command is received in thefirst to third embodiments, the present invention is not limited to thistiming. For example, the swap necessity judgement result of therecording state judgement unit 126 may be held in the physical areamanagement table 131 or the like and the memory module may search thephysical area management table 131 and if necessary in the nextinitialization processing. Furthermore, the memory module may divide theswap processing into a first half and second half and perform the firsthalf of the swap along with the writing processing performed each timethe write command is received and may perform the second half in theinitialization processing.

INDUSTRIAL APPLICABILITY

The nonvolatile storage system of the present invention employs a methodof achieving both the long lifetime and high writing speed, and isuseful for a still image recording and reproduction devices, movingimage recording and reproduction devices and mobile phones which use thenonvolatile storage module such as the semiconductor memory card.

1. A memory controller connected to a nonvolatile memory, the memorycontroller reading and writing data according to an external accessinstruction comprising: an address management unit for managing at leastfree area of said nonvolatile memory and selecting a writing destinationarea from the free area of said nonvolatile memory at data writing; arecording state judgement unit for performing swap necessity judgementof a storage area based on a recording state of said nonvolatile memory;and a reading and writing control unit for controlling data reading andwriting, determining a swap target area according to a judgement resultof said recording state judgement unit and performing swap processing.2. The memory controller according to claim 1, wherein said recordingstate judgement unit performs swap necessity judgement based on numbersof times of rewriting of physical blocks which constitute saidnonvolatile memory.
 3. The memory controller according to claim 2,wherein said recording state judgement unit judges necessity of swapbased on a maximum value of said numbers of times of rewriting and oneof an average value and a minimum value of said numbers of times ofrewriting.
 4. The memory controller according to claim 1, wherein saidreading and writing control unit determines a swap target area based onnumbers of times of rewriting of physical blocks which constitute saidnonvolatile memory.
 5. The memory controller according to claim 1,wherein said reading and writing control unit determines a swap targetarea based on numbers of times of rewriting of physical blocks whichconstitute said nonvolatile memory and depending on whether or not aphysical block is a free physical block.
 6. The memory controlleraccording to claim 1, wherein said memory controller further includes alifetime judgement unit for judging lifetime relating to a dataretention time of data stored in said nonvolatile memory and informingthe lifetime information to outside.
 7. The memory controller accordingto claim 1, wherein said memory controller further includes: a systemcondition reception unit for receiving a system condition designatedfrom outside: and a system condition judgement unit for performing swappossibility judgement of a storage area based on said system condition,and said reading and writing control unit controls data reading andwriting and performs determination of a swap target area and swapprocessing according to judgement results of said recording statejudgement unit and said system condition judgement unit.
 8. The memorycontroller according to claim 7, wherein said system condition is atleast one of a requirement relating to access speed, requirementrelating to power, requirement relating to power and requirementrelating to lifetime measure.
 9. The memory controller according toclaim 7, wherein said system condition judgement unit determines anumber of swap based on said system condition.
 10. The memory controlleraccording to claim 7, wherein said system conditions reception unitreceives information on a type of said nonvolatile memory, and saidsystem condition judgement unit performs swap possibility judgementaccording to the type of the said nonvolatile memory.
 11. The memorycontroller according to claim 7, wherein said system condition receptionunit receives information on a type of said nonvolatile storage modulemounting the memory controller thereon, and said system conditionjudgement unit judges possibility of swap according to the type of saidnonvolatile storage module.
 12. A nonvolatile storage module for readingand writing data according to an external access instruction comprising:a nonvolatile memory; and a memory controller connected to saidnonvolatile memory for reading and writing data according to theexternal access instruction, wherein: said memory controller includes:an address management unit for managing at least free area of saidnonvolatile memory and selecting a writing destination area from thefree area of said nonvolatile memory at data writing; a recording statejudgement unit for performing swap necessity judgement of a storage areabased on a recording state of said nonvolatile memory; and a reading andwriting control unit for controlling data reading and writing,determining a swap target area according to judgement result of saidrecording state judgement unit and performing swap processing.
 13. Thenonvolatile storage module according to claim 12, wherein said memorycontroller further includes a lifetime judgement unit for judging alifetime relating to a data retention time of data stored in saidnonvolatile memory and informing lifetime information to outside. 14.The nonvolatile storage module according to claim 12, wherein saidmemory controller further includes: a lifetime judgement unit forjudging a lifetime relating to a data retention time of data stored insaid nonvolatile memory and informing lifetime information to theoutside; a system condition reception unit for receiving a systemcondition designated from the outside; and a system condition judgementunit for performing swap possibility judgement of a storage area basedon said system condition, and said reading and writing control unitcontrols data reading and writing and performs determination of a swaptarget area and swap processing according to judgement results of saidrecording state judgement unit and said system condition judgement unit.15. The nonvolatile storage module according to claim 14, wherein saidsystem condition reception unit receives information on a type of saidnonvolatile memory, and said system condition judgement unit performsswap possibility judgement according to the type of said nonvolatilememory.
 16. The nonvolatile storage module according to claim 14,wherein said system condition reception unit receives information on thetype of said nonvolatile storage module mounting said memory controllerthereon, and said system condition judgement unit performs swappossibility judgement according the type of said nonvolatile storagemodule.
 17. An access module connected to the nonvolatile storage moduleaccording to claim 13, the access module writing data to saidnonvolatile storage module and reading data from said nonvolatilestorage module comprising: a lifetime information display unit fordisplaying lifetime information received from said nonvolatile storagemodule.
 18. An access module connected to the nonvolatile storage moduleaccording to claim 14, the access module writing data to saidnonvolatile storage module and reading data from said nonvolatilestorage module comprising: a system condition informing unit forinforming said system condition to said nonvolatile storage module. 19.A nonvolatile storage system comprising: an access module; and anonvolatile storage module for reading and writing data according to anaccess instruction from said access module, wherein said nonvolatilestorage module includes: a nonvolatile memory; and a memory controllerconnected to said nonvolatile memory, the memory controller reading andwriting data according to an external access instruction, said memorycontroller includes: an address management unit for managing at leastfree area of said nonvolatile memory and selecting a writing destinationarea from the free area of said nonvolatile memory at data writing; arecording state judgement unit for performing swap necessity judgementof a storage area based on a recording state of said nonvolatile memory;and a reading and writing control unit for controlling data reading andwriting, and determining a swap target area according to a judgementresult of said recording state judgement unit and performing swapprocessing.
 20. The nonvolatile storage system according to claim 19,wherein said memory controller includes a lifetime judgement unit forjudging a lifetime relating to a data retention time of data stored insaid nonvolatile memory and informing the lifetime information to saidaccess module.
 21. The nonvolatile storage system according to claim 19,wherein said memory controller further includes: a system conditionreception unit for receiving a system condition designated from saidaccess module; and a system condition judgement unit for performing swappossibility judgement of a storage area based on said system condition;and said reading and writing control unit controls data reading andwriting and performs determination of a swap target area and swapprocessing according to judgement results of said recording statejudgement unit and said system condition judgement unit.
 22. Thenonvolatile storage system according to claim 21, wherein said systemcondition is at least one of a requirement relating to access speed,requirement relating to power, requirement relating to power andrequirement relating to lifetime measure.
 23. The nonvolatile storagesystem according to claim 21, wherein said system condition judgementunit determines a number of swap based on said system condition.
 24. Thenonvolatile storage system according to claim 21, wherein said systemcondition reception unit receives information on a type of saidnonvolatile memory, and said system condition judgement unit performsswap possibility judgement according the type of said nonvolatilememory.
 25. The nonvolatile storage system according to claim 21,wherein said system condition reception unit receives information on thetype of said nonvolatile storage module mounting said memory controllerthereon, and said system condition judgement unit performs swappossibility judgement according to the type of said nonvolatile storagemodule mounting the memory controller thereon.